﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Collections;
using ERMap;

namespace PhoneBook.Group
{
    public class Department
    {
        public static DataSet list(string groupid)
        {
            Hashtable keys = new Hashtable();
            keys["groupid"] = groupid;
            return ERMapHelper.getdata("b_department", keys);
        }

        public static DataSet list(string groupid, string boid)
        {
            Hashtable keys = new Hashtable();
            keys["groupid"] = groupid;
            keys["boid"] = boid;
            return ERMapHelper.getdata("b_department", keys);
        }

        public static DataSet listforunit(string groupid)
        {
            Hashtable keys = new Hashtable();
            keys["groupid"] = groupid;
            string strSql = "select * from b_department where groupid = @groupid and boid is null and isnull(isdel,0)=0";
            return ERMapHelper.getCustomData(strSql, keys);
        }

        public static void del(string departmentid)
        {
            Hashtable keys = new Hashtable();
            keys["departmentid"] = departmentid;
            ERMapHelper.delmodel("b_department", keys);
        }

        public static void add(Hashtable department)
        {
            department["departmentid"] = "";
            ERMapHelper.setmodel("b_department", "departmentid", department);
        }

        public static Hashtable get(string departmentid)
        {
            Hashtable keys = new Hashtable();
            keys["departmentid"] = departmentid;
            return ERMapHelper.getmodel("b_department", keys);
        }

        public static void edit(Hashtable department)
        {
            ERMapHelper.setmodel("b_department", "departmentid", department);
        }

        public static string getmaxid()
        {
            return ERMapHelper.maxid("b_department", "departmentid");
        }
    }
}
